import time
from data011.Base.Base import Base
from selenium.webdriver.common.by import By

class Page1(Base):
    # 点击请登录     class="headerLogin"
    headerLogin_loc = (By.CLASS_NAME,'headerLogin')
    def headerLogin(self):
        self.click(self.headerLogin_loc)
    # 断言1
    dy1_loc = (By.XPATH,'//*[@id="loginform"]/div/div/div/div/div[1]/div[1]/a[1]')
    def dy1(self):
        return self.text(self.dy1_loc)
    # 账号
    userName_loc = (By.ID,'userName')
    def userName(self,usm):
        self.send_keys(self.userName_loc,usm)
    # 密码
    password_loc = (By.ID,'password')
    def password(self,paw):
        self.send_keys(self.password_loc,paw)
    # 登录
    dl_click = (By.ID,'save')
    def dl(self):
        self.click(self.dl_click)
    # 点击确定  bindSub
    bindSub_loc = (By.ID,'bindSub')
    def bindSub(self):
        self.click(self.bindSub_loc)
    dy2_loc = (By.XPATH,'/html/body/div[2]/div/div[1]/div/p/span')
    def dy2(self):
        return self.text(self.dy2_loc)

    def test_jiouxian_01(self,usm,paw):
        self.open_url('https://www.jiuxian.com/')
        self.headerLogin()
        time.sleep(2)
        print('进入登录页面断言:',self.dy1())
        assert self.dy1() == '帐号登录'
        time.sleep(2)
        self.userName(usm)
        self.implicitly_wait(10)
        self.password(paw)
        time.sleep(10)
        self.dl()
        self.bindSub()
        time.sleep(4)
        print('登录成功断言:', self.dy2())
        assert self.dy2() == 'jxw357734689'
        time.sleep(2)


